package com.ruoyi.infoManagement.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.Regexregisteredservice;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.infoManagement.service.IRegexregisteredserviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.net.MalformedURLException;
import java.util.List;
import java.util.Map;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2022-03-23
 */
@RestController
@RequestMapping("/infoManagement/regexregisteredservice")
public class RegexregisteredserviceController extends BaseController {
  @Autowired
  private IRegexregisteredserviceService regexregisteredserviceService;

  /**
   * 查询【请填写功能名称】列表
   */
  @PreAuthorize("@ss.hasPermi('infoManagement:regexregisteredservice:list')")
  @GetMapping("/list")
  public TableDataInfo list(Regexregisteredservice regexregisteredservice) {
    startPage();
    List<Regexregisteredservice> list = regexregisteredserviceService.selectRegexregisteredserviceList(regexregisteredservice);
    return getDataTable(list);
  }

  @PreAuthorize("@ss.hasPermi('infoManagement:regexregisteredservice:queryByParameter')")
  @PostMapping("/queryByParameter")
  public AjaxResult queryByParameter(@RequestBody Map map) {
    System.out.println(map);
    Regexregisteredservice regexregisteredservice=new Regexregisteredservice();
    if(map.get("name")!=null){
      regexregisteredservice.setName(map.get("name").toString());
    }else {
      regexregisteredservice.setLogoutUrl(map.get("logoutUrl").toString());
    }
    List<Regexregisteredservice> list = regexregisteredserviceService.selectRegexregisteredserviceList(regexregisteredservice);
    return AjaxResult.success(list);
  }
  /**
   * 导出【请填写功能名称】列表
   */
  @PreAuthorize("@ss.hasPermi('infoManagement:regexregisteredservice:export')")
  @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
  @GetMapping("/export")
  public AjaxResult export(Regexregisteredservice regexregisteredservice) {
    List<Regexregisteredservice> list = regexregisteredserviceService.selectRegexregisteredserviceList(regexregisteredservice);
    ExcelUtil<Regexregisteredservice> util = new ExcelUtil<Regexregisteredservice>(Regexregisteredservice.class);
    return util.exportExcel(list, "【请填写功能名称】数据");
  }

  /**
   * 获取【请填写功能名称】详细信息
   */
  @PreAuthorize("@ss.hasPermi('infoManagement:regexregisteredservice:query')")
  @GetMapping(value = "/{id}")
  public AjaxResult getInfo(@PathVariable("id") Long id) {
    return AjaxResult.success(regexregisteredserviceService.selectRegexregisteredserviceById(id));
  }

  /**
   * 新增【请填写功能名称】
   */
  @PreAuthorize("@ss.hasPermi('infoManagement:regexregisteredservice:add')")
  @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
  @PostMapping
  public Map add(@RequestBody Regexregisteredservice regexregisteredservice) throws MalformedURLException {

    return regexregisteredserviceService.insertRegexregisteredservice(regexregisteredservice);
  }

  /**
   * 修改【请填写功能名称】
   */
    @PreAuthorize("@ss.hasPermi('infoManagement:regexregisteredservice:edit')")
  @Log(title = "修改service", businessType = BusinessType.UPDATE)
  @PostMapping("/edit")
  public Map edit(@RequestBody Regexregisteredservice regexregisteredservice) {

    return regexregisteredserviceService.updateRegexregisteredservice(regexregisteredservice);
  }

  /**
   * 删除【请填写功能名称】
   */
  @PreAuthorize("@ss.hasPermi('infoManagement:regexregisteredservice:remove')")
  @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
  @DeleteMapping("/{ids}")
  public AjaxResult remove(@PathVariable Long[] ids) {
    System.out.println(ids);
    return toAjax(regexregisteredserviceService.deleteRegexregisteredserviceByIds(ids));
  }
}
